#!/usr/bin/env python
# encoding: utf-8
"""
ep2.py

Created by Luciano Ramalho on 2007-05-09.
"""
import sys
from cmath import sqrt

epsilon = float(sys.stdin.readline())
n = int(sys.stdin.readline())
assert n >= 1
print "                    Raizes de Equacoes Quadraticas"
print "-------------------------------------------------------------------------------"
print "     coeficientes       tipo das"
print "   a      b      c      solucoes       raiz 1                raiz 2"
print "-------------------------------------------------------------------------------"
# print "  9.99  -9.99  99.99   xxxxxxxxx       9.0000 + i*9.0000     9.0000 - i*9.0000"

for i in range(n):
    a,b,c = [float(x) for x in sys.stdin.readline().split()]
    msg = None
    if a < epsilon:
        msg = "*** ERRO: equacao nao e do segundo grau! ***"
    else:
        r1_imag_str = ''
        r2_imag_str = ''
        delta = b*b-4.0*a*c
        r2delta = sqrt(delta)
        r1 = (-b + r2delta) / (2.0 * a)
        r2 = (-b - r2delta) / (2.0 * a)
        if abs(delta) < epsilon:
            tipo = "real dupla"
        elif delta > 0.0:
            tipo = "reais simples"            
        else:
            tipo = "complexas"
            r1_imag_str = " + i*%.4f" % r1.imag
            r2_imag_str = " - i*%.4f" % r1.imag
        msg =  "%-13s %8.4f%-13s %8.4f%s" % (tipo, r1.real, r1_imag_str, r2.real, r2_imag_str)
    print "%6.2f %6.2f %6.2f   %s" % (a, b, c, msg)
    
    
